﻿<!DOCTYPE html>
<html>
<head>
    <title>农商互联开发平台</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <!--    <link href="/static/css/dialog.css" rel="stylesheet"/>-->
    <!--    <script src="/static/js/dialog.js"></script>-->
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>


    <!--开关主键-->
    <script src="/static/bootstrap/bootstrap-switch.js"></script>
    <link href="/static/bootstrap/bootstrap-switch.css" rel="stylesheet"/>

    <!-- PNotify -->
    <script type="text/javascript" src="/static/pnotify/pnotify.js"></script>
    <link href="/static/pnotify/pnotify.css" rel="stylesheet" type="text/css"/>
    <link href="/static/pnotify/pnotify.brighttheme.css" rel="stylesheet" type="text/css"/>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
</head>
<body>


<div class="newtest">
    <div class="new_main">

        <div style="padding-top:15px;padding-left:15px;">
            <button class="btn-sm btn-warning" onClick="javascript :history.back(-1);">返回上一级</button>
        </div>

        <div class="row order_detail">
            <div class="col-md-6">

                <div class="order-heading">
                    <h3>订单信息</h3>
                </div>


                <div class="order_table">
                    <table style="text-align: left">

                        <tr>
                            <td> 购买人UID：</td>
                            <td> {$order.fans_id}</td>
                        </tr>

                        <tr>
                            <td> 订单金额：</td>
                            <td>{$order.total_amount}</td>
                        </tr>

                        <tr>
                            <td> 订单编号：</td>
                            <td>{$order.order_sn}</td>
                        </tr>


                        <tr>
                            <td> 第三方支付单号：</td>
                            <td>{$order.out_trade_order_id}</td>
                        </tr>
<!--                        {if condition="$order.out_trade_order_id neq ''"}{/if}-->

                        <tr>
                            <td> 订单状态：</td>
                            <td>{$order.status_name}</td>
                        </tr>

                        <tr>
                            <td> 购买票种：</td>
                            <td>{$detail.title}</td>
                        </tr>
                        <tr>
                            <td> 票种id：</td>
                            <td>{$detail.tickets_id}</td>
                        </tr>

                        <tr>
                            <td> 票种类型：</td>
                            <td>{$detail.type_name}</td>
                        </tr>

                        <tr>
                            <td> 单价：</td>
                            <td> {$detail.price}</td>
                        </tr>

                        <tr>
                            <td> 下单人信息：</td>
                            <td>{$order.name} </td>
                        </tr>

                        <tr>
                            <td> 电话：</td>
                            <td> {$order.mobile}</td>
                        </tr>

                        <tr>
                            <td> 身份证号：</td>
                            <td> {$order.IDcard}</td>
                        </tr>

                        <tr>
                            <td> 备注：</td>
                            <td>{$order.remark}</td>
                        </tr>

                        <tr>
                            <td> 购买数量：</td>
                            <td> {$detail.count}</td>
                        </tr>
                        <tr>
                            <td> 支付方式：</td>
                            <td>{$order.pay_type}</td>
                        </tr>

                        <tr>
                            <td> 支付状态：</td>
                            <td>{$order.is_pay}</td>
                        </tr>

                        <tr>
                            <td> 下单时间：</td>
                            <td>{$order.addtime|date="Y-m-d H:i:s",###}</td>
                        </tr>
                        {if condition="$order.status eq 6"}
                        <tr>
                            <td> 取消原因：</td>
                            <td>{$order.cancel_reason}</td>
                        </tr>

                        <tr>
                            <td> 取消备注：</td>
                            <td>{$order.cancel_remark}</td>
                        </tr>
                        {/if}

                    </table>
                </div>

            </div>
            <div class="col-md-6 operation">

                    <div class="order-heading">
                        <h3>订单日志</h3>
                    </div>

                    <div class="operation_btn show_logo">
                        {volist name="log" id="vo"}
                        <div class="order_log">
                            <p>
                                <i class="fa fa-info-circle" ></i><b>{$vo.addtime|Date="Y-m-d H:i:s",###} {$vo.title}</b>
                            </p>
                            <p>{$vo.remark}</p>
                        </div>
                        {/volist}
                    </div>

                    <div class="order-heading">
                        <h3>订单操作</h3>
                    </div>

                    <div class="operation_btn">
                        <button class="btn btn-primary updateOrder" data-id="{$order.id}">修改订单</button>
                        {if condition="$order['status']==1"}
                        <button class="btn btn-primary receive" data-id="{$order.id}" data-title="提示" data-msg="确定设为待核销状态吗？"
                                data-id="{$order.id}" data-operation="confirm">待核销
                        </button>
                        {/if}

                        {if condition="$order['status']!=6"}
                        <button class="btn btn-primary receive" data-id="{$order.id}" data-title="提示"
                                data-msg="确定取消订单吗" data-id="{$order.id}" data-operation="cancel">取消订单
                        </button>
                        {/if}

<!--                        {if condition="$order['refund']==1 && $order['pay_type'] != '3' && $order['status']==2"}-->
<!--                        <button class="btn btn-danger receive" data-id="{$order.id}" data-title="提示" data-msg="确定退款吗"-->
<!--                                data-id="{$order.id}" data-operation="refund">立即退款-->
<!--                        </button>-->
<!--                        {/if}-->

                        {if condition="$order['status']!=6 && $order['status']!=3"}
                        <button class="btn btn-primary receive" data-id="{$order.id}" data-title="提示"
                                data-msg="确定设为已核销状态吗" data-id="{$order.id}" data-operation="complete">已核销
                        </button>
                        {/if}

<!--                        <button class="btn btn-primary receive" data-title="提示" data-msg="确定删除该订单吗"-->
<!--                                data-id="{$order.id}" data-operation="delete">删除操作-->
<!--                        </button>-->

<!--                        <button class="btn btn-primary print" data-id="{$order.id}" data-operation="delete">打印订单-->
<!--                        </button>-->
                    </div>

                </div>

            </div>

            <div class="col-md-12 ">
                <div class="order_table">
                <div class="order-heading">
                    <h3>门票信息</h3>
                </div>
                <table>
                    <tr>
                        <th style="width:230px!important;">票编码</th>
                        <th>生效时间</th>
                        <th>过期时间</th>
                        <th>剩余检票次数</th>
                        <th>最近检票时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo.signcode}</td>
                        <td>{$vo.effective_time}</td>
                        <td>{$vo.end_time}</td>
                        <td>{$vo.degree}</td>
                        <td>{$vo.check_time}</td>
                        <td>{$vo.status_name}</td>
                        <td><button class="btn-sm btn-danger cartDel" data-val="{$vo.id}">作废</button></td>
                    </tr>
                    {/volist}
                </table>

                </div>
            </div>
        </div>
    </div>

</div>
</body>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>


<script>
    $(function () {
        $(this).find('.modal-dialog').css({
            'width': '1000px'
        });
    });

    //打印订单
    $(".print").click(function () {
        var id = $(this).attr("data-id");
        $.ajax({
            type: "post",
            url: "{:URL('home/Order/printer')}",
            data: {id: id},
            dataType: "json",
            success: function (data) {
                layer.alert(data.msg);

            }
        });
    });

    var modal = new yii.modal();

    $(".receive").click(function () {
        var title = $(this).attr("data-title");
        var msg = $(this).attr("data-msg");
        var id = $(this).attr("data-id");
        var operation = $(this).attr("data-operation");
        var data = {title: title, msg: msg, id: id, operation: operation};
        modal.initialization({
            url: "{:URL('common/Common/bounced')}",
            type: "post",
            data: data
        });
    });


    //修改订单
    $(".updateOrder").click(function () {
        var id = $(this).attr("data-id");
        modal.initialization({
            url: "{:URL('tickets/order/updateAddress')}",
            type: "post",
            data: {
                type: 'detail',
                id: id
            }
        });
    });

    //修改页面
    $(".update").click(function () {
        var id = $(this).attr("data-id");
        modal.initialization({
            url: "{:URL('home/Product/addProduct')}",
            type: "post",
            data: {
                type: 'detail',
                id: id
            }
        });
    });

    layui.use(['form', 'layedit'], function () {
        var layedit = layui.layedit;
        //统一modal执行保存action
        modal.on("add", function (data) {
            var data = $(modal.getid()).find("form").serialize();

            $.ajax({
                type: "post",
                url: indexinfo.addStore,
                data: data,
                dataType: "json",
                success: function (data) {
                    layer.alert(data.msg);
                    if (data.status == 'success') {
                        window.location.reload();
                    }
                }
            });
        });


        //退款操作
        modal.on("refund", function (data) {
            var id = $(modal.getid()).find(".btn-primary").attr("_data");
            var data = {id: id, status: "refund"};
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateStatus')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 'success') {
                        window.location.reload();
                    } else {
                        layer.alert(data.msg);
                    }
                }
            });
        });


        //设为已付款
        modal.on("confirm", function (data) {
            var id = $(modal.getid()).find(".btn-primary").attr("_data");
            var data = {id: id, status:2};
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateStatus')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 'success') {
                        window.location.reload();
                    }else{
                        layui.alert(data.msg)
                    }
                }
            });
        });

        //完成订单
        modal.on("complete", function (data) {
            var id = $(modal.getid()).find(".btn-primary").attr("_data");
            var data = {id: id, status: 3};
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateStatus')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 'success') {
                        window.location.reload();
                    }
                }
            });
        });

        //取消订单
        modal.on("cancel", function (data) {
            var id = $(modal.getid()).find(".btn-primary").attr("_data");
            var cancel_reason = $(modal.getid()).find(".cancel_select").val();
            var cancel_remark = $(modal.getid()).find(".cancel_remark").val()
            var data = {id: id, status: 6, cancel_reason: cancel_reason, cancel_remark: cancel_remark};
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateStatus')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 'success') {
                        window.location.reload();
                    } else {
                        layer.alert(data.msg);
                    }
                }
            });
        });

        //删除订单
        modal.on("delete", function (data) {
            var id = $(modal.getid()).find(".btn-primary").attr("_data");
            var data = {id: id, status: 'del'};
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateStatus')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 'success') {
                        window.location.href = "{:URL('tickets/Order/index')}";
                    }
                }
            });
        });


        modal.on("updateAddress", function (data) {
            var data = $(modal.getid()).find("form").serializeArray();
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/updateAddress')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    layer.alert(data.msg);
                    if (data.status == 'success') {
                        window.location.reload();
                    }
                }
            });
        });

        $(".cartDel").click(function () {
            var id = $(this).attr("data-val");
            $.ajax({
                type: "post",
                url: "{:URL('tickets/order/cartDel')}",
                data: {id:id},
                dataType: "json",
                success: function (data) {
                    layer.alert(data.msg);
                    if (data.code == 0) {
                        window.location.reload();
                    }
                }
            });
        });

    });

</script>


</html>
